package com.spring.framework.spel;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalTime;

@Component
public class AnnotationDemo2 {
	private String birthplace;
	private LocalDate birthDate;
	@Value("#{T(java.time.LocalTime).now()}")
	private LocalTime birthTime;

	@Value("#{T(java.time.LocalDate).now()}")
	public void setBirthDate(LocalDate birthDate) {
		this.birthDate = birthDate;
	}

	public AnnotationDemo2(@Value("#{T(java.lang.Math).random() * ${birthplace}}")
								   String birthplace) {
		this.birthplace = birthplace;
	}

	/**
	 * 导航的属性，要求必须是public修饰的或者提供了相应的getter方法
	 */
	public String getBirthplace() {
		return birthplace;
	}

	@Override
	public String toString() {
		return "AnnotationDemo2{" +
				"birthplace='" + birthplace + '\'' +
				", birthDate=" + birthDate +
				", birthTime=" + birthTime +
				'}';
	}
}
